import { request, post, get } from "@/utils/request";
import axios from "axios";

class CustomerApi {
  /**
   * @description: 添加客群
   * @param {*}
   * @return {*}
   */
  // addUserGroup(data) {
  //   let url = `/user/userGroup/saveOrUpdateUserGroup`;
  //   return request(url, data);
  // }

  addUserGroup(data) {
    let url = `/user/dynamicUserGroup/saveOrUpdateUserDynamicGroup`;
    return request(url, data);
  }



  /**
   * @description: 删除客群
   * @param {*}
   * @return {*}
   */
  delUserGroup(data) {
    let url = `/user/userGroup/delUserGroup`;
    return request(url, data);
  }
  /**
   * @description: 删除客群用户
   * @param {*}
   * @return {*}
   */
  delGroupUser(data) {
    let url = `/user/userGroupUser/delUser`;
    return request(url, data);
  }
  /**
   * @description: 导入客群用户模板下载
   * @param {*}
   * @return {*}
   */
  downExcelTemplate(data) {
    let url = `/user/userGroupUser/downExcelTemplate?userGroupId=${data.userGroupId}`;
    return get(url, {
      responseType: "blob",
    });
  }

  /**
   * @description: 导入客群用户
   * @param {*}
   * @return {*}
   */
  exportCustomerExcel(data) {
    let url = `/user/userGroupUser/exportExcel`;
    return request(url, data);
  }

  /**
   * @description: 删除用户
   * @param {*}
   * @return {*}
   */
  delUser(data) {
    let url = `/user/userEntity/del`;
    return request(url, data);
  }

  /**
   * @description: 添加客群属性
   * @param {*}
   * @return {*}
   */
  saveOrUpdateProperty(data) {
    let url = `/user/userGroupProperty/saveOrUpdateProperty`;
    return request(url, data);
  }

  /**
   * @description: 删除客群属性
   * @param {*}
   * @return {*}
   */
  delProperty(data) {
    let url = `/user/userGroupProperty/delProperty`;
    return request(url, data);
  }

  /**
  * @description: 获取客群分类的树
  * @param {*}
  * @return {*}
  */
  getCustomersGroupTree(data) {
    let url = `/user/userGroup/categoryEntity/findAll`;
    return request(url, data);
  }

  /**
 * @description: 添加或编辑客群分类的分组
 * @param {*}
 * @return {*}
 */
  setGroupTreeSaveOrUpdate(data) {
    let url = `/user/userGroup/categoryEntity/saveOrUpdate`;
    return request(url, data);
  }
  /**
* @description: 添加或编辑客群分类的分组
* @param {*}
* @return {*}
*/
  delCustomersGroupTree(data) {
    let url = `/user/userGroup/categoryEntity/removeById`;
    return request(url, data);
  }

  /**
* @description: 添加或编辑客群分类的分组
* @param {*}
* @return {*}
*/
  updateCategoryBatch(data) {
    let url = `/user/userGroup/categoryEntity/updateCategoryBatch`;
    return request(url, data);
  }


  /**
* @description: 根据客群id查客群的基础属性
* @param {*}
* @return {*}
*/
  getInfoGroup(data) {
    let url = `/user/userGroup/getInfo`;
    return request(url, data);
  }


  /**
* @description: 智能客群状态修改
* @param {*}
* @return {*}
*/
  setSmartGroupState(data) {
    let url = `/user/dynamicUserGroup/start`;
    return request(url, data);
  }



  /**
   * @description: 添加客群独有的属性
   * @param {*}
   * @return {*}
   */
  addProperty(data) {
    let url = `/user/userGroupProperty/addProperty`;
    return request(url, data);
  }
  /**
   * @description: 客群属性所有的不分页
   * @param {*}
   * @return {*}
   */
  propertyList(data) {
    let url = `/user/userGroupProperty/propertyList`;
    return request(url, data);
  }


  /**
  * @description: 获取动态客群的规则参数
  * @param {*}
  * @return {*}
  */
  getDynamicUserGroup(data) {
    let url = `/user/dynamicUserGroup/getInfo`;
    return request(url, data);
  }

  /**
   * @description: 设置动态客群对的规则
   * @param {*}
   * @return {*}
   */
  setDynamicUserGroup(data) {
    let url = `/user/dynamicUserGroup/saveOrUpdateUserGroup`;
    return request(url, data);
  }
  /**
   * @description: 添加属性
   * @param {*}
   * @return {*}
   */
  createOrUpdate(data) {
    let url = `/user/propertyEntity/createOrUpdate`;
    return request(url, data);
  }

  /**
   * @description: 删除属性
   * @param {*}
   * @return {*}
   */
  delAttribute(data) {
    let url = `/user/propertyEntity/del`;
    return request(url, data);
  }



  /**
   * @description: 获取标签分组的结构树
   * @param {*}
   * @return {*}
   */
  getTagGroupTree(data) {
    let url = `/user/tag/categoryEntity/findAll`;
    return request(url, data);
  }

  /**
   * @description: 批量修改标签所在的分组
   * @param {*}
   * @return {*}
   */
  updateTagCategoryBatch(data) {
    let url = `/user/tag/categoryEntity/updateCategoryBatch`;
    return request(url, data);
  }

  getCanvasProperty
  /**
   * @description: 添加编辑分组的分组
   * @param {*}
   * @return {*}
   */
  getTagGroupTreeSaveOrUpdate(data) {
    let url = `/user/tag/categoryEntity/saveOrUpdate `;
    return request(url, data);
  }



  /**
   * @description: 标签集合
   * @param {*}
   * @return {*}
   */
  attributeList(data) {
    let url = `/user/propertyEntity/pageList`;
    return request(url, data);
  }

  /**
   * @description: 属性模板导入
   * @param {*}
   * @return {*}
   */
  exportExcel(data) {
    let url = `/user/propertyEntity/exportExcel`;
    return request(url, data);
  }

  /**
   * @description: 修改积分
   * @param {*}
   * @return {*}
   */
  updateIntegral(data) {
    let url = `/user/currency/updateIntegral`;
    return request(url, data);
  }

  // --------------------------画布--------------------------------

  /**
   * @description: 统计 画布 按状态
   * @param {*}
   * @return {*}
   */
  canvasCurrent(data) {
    let url = `/flow/canvas/data`;
    return request(url, data);
  }

  /**
   * @description: 恢复开启 画布
   * @param {*}
   * @return {*}
   */
  recoveryCanvas(data) {
    let url = `/flow/canvas/recovery`;
    return request(url, data);
  }

  /**
   * @description: 停止画布
   * @param {*}
   * @return {*}
   */
  stopCanvas(data) {
    let url = `/flow/canvas/stop`;
    return request(url, data);
  }

  /**
   * @description: 暂停画布
   * @param {*}
   * @return {*}
   */
  pauseCanvas(data) {
    let url = `/flow/canvas/pause`;
    return request(url, data);
  }

  /**
   * @description: 发布 画布
   * @param {*}
   * @return {*}
   */
  publishCanvas(data) {
    let url = `/flow/canvas/publish`;
    return request(url, data);
  }

  /**
   * @description: 取消发布 画布
   * @param {*}
   * @return {*}
   */
  cancelPublishCanvas(data) {
    let url = `/flow/canvas/cancelPublish`;
    return request(url, data);
  }

  /**
   * @description: 复制 画布
   * @param {*}
   * @return {*}
   */
  copyCanvas(data) {
    let url = `/flow/canvas/copy`;
    return request(url, data);
  }

  /**
   * @description: 删除 画布
   * @param {*}
   * @return {*}
   */
  delCanvas(data) {
    let url = `/flow/canvas/del`;
    return request(url, data);
  }

  /**
   * @description 节点每日数据 折线图
   * @param data
   * @param {number} data.nodeId - 主键id
   * @param {number} data.canvasId - canvasId
   * @param {number} data.merchantId - merchantId
   * @returns {Promise<AxiosResponse<any>>}
   */
  getDataByNodeId(data) {
    return request("/flow/canvasRecordDataEntity/getDataByNodeId", data);
  }

  /**
   * 节点每日数据 表
   * @param data
   * @param {number} data.nodeId - 节点ID
   * @param {number} data.canvasId - 图ID
   * @param {number} data.merchantId - 商户ID
   * @param {number} data.currentPage - 分页
   * @param {number} data.showCount - 页面大小
   * @returns {Promise<AxiosResponse<any>>}
   */
  getDataByNodeIdWithPage(data) {
    return request(
      "/flow/canvasRecordDataEntity/getDataByNodeIdWithPage",
      data
    );
  }

  /**
   * @description 节点详细数据 导出
   * @param data
   * @param {number} data.nodeId
   * @param {number} data.canvasId
   * @returns {Promise<AxiosResponse<any>>}
   */
  detailExportData(data) {
    return request("/flow/canvasRecordDataEntity/exportData", data, {
      responseType: "blob",
    });
  }

  /**
   * @description: 营销流程日历列表
   * @param {*}
   * @return {*}
   */
  getCalenderList(data) {
    let url = `/flow/canvas/pageListByMonth`;
    return request(url, data);
  }

  /**
   * @description: 客户详情
   * @param {*}
   * @return {*}
   */
  getInfo(data) {
    let url = `/user/userEntity/getInfo`;
    return request(url, data);
  }
  /**
   * @description: 变更属性
   * @param {*}
   * @return {*}
   */
  propertyChange(data) {
    let url = `/user/userTagEntity/userTagsChange`;
    return request(url, data);
  }

  /**
   * @description: 清除缓存
   * @param {*}
   * @return {*}
   */
  clearCacheSubmit(data) {
    let url = `/user/userTagEntity/delUserTagsCache`;
    return request(url, data);
  }



  /**
   * @description: 标签分组列表
   * @param {*}
   * @return {*}
   */
  getTagGroupList(data) {
    let url = `/user/tagGroupEntity/page`;
    return request(url, data);
  }

  /**
  * @description: 根据分组id查询分组下所有标签 
  * @param {*}
  * @return {*}
  */
  getTagPageByGroupId(data) {
    let url = `/user/tagGroupEntity/tagPageByGroupId `;
    return request(url, data);
  }

  /**
   * @description: 删除标签分组
   * @param {*}
   * @return {*}
   */
  delTagGroup(data) {
    let url = `/user/tag/categoryEntity/removeById`;
    return request(url, data);
  }

  /**
   * @description: 添加标签分组
   * @param {*}
   * @return {*}
   */
  addTagGroup(data) {
    let url = `/user/tag/categoryEntity/saveOrUpdate`;
    return request(url, data);
  }


  /**
  * @description: 获取会员等级 由于会员相关代码没有更新 临时放在此处  后续会员代码更新后请引用同一个
  * @param {*}
  * @return {*}
  */
  queryVipMemInfo() {
    let url = `/merchant/memInfo/queryMemInfo`;
    return request(url);
  }


  /**
  * @description: 批量移出客群
  * @param {*}
  * @return {*}
  */
  delUserBatch(data) {
    let url = `/user/userGroupUser/delUserBatch`;
    return request(url, data);
  }

  /**
  * @description: 全部移出客群
  * @param {*}
  * @return {*}
  */
  delEmptyAll(data) {
    let url = `/user/userGroupUser/empty`;
    return request(url, data);
  }

  /**
  * @description: 客群导入方式
  * @param {*}
  * @return {*}
  */
  thirdLogin() {
    let url = `/user/userGroupUser/thirdLogin/types`;
    return request(url);
  }
  


  /**
  * @description: 获取单个客户卡券信息
  * @param {*}
  * @return {*}
  */
  getCouponInfo(data) {
    let url = `/user/userEntity/getCouponInfo`;
    return request(url, data);
  }
  /**
  * @description: 根据用户id获取收货地址
  * @param {*}
  * @return {*}
  */
  getAddressByUserId(data) {
    let url = `/user/userEntity/getAddressByUserId`;
    return request(url, data);
  }
  /**
  * @description: 根据用户id获取积分使用情况
  * @param {*}
  * @return {*}
  */
  getCurrencyInfo(data) {
    let url = `/user/userEntity/getCurrencyInfo`;
    return request(url, data);
  }
  /**
  * @description: 根据用户id获取商城数据
  * @param {*}
  * @return {*}
  */
  getMallInfo(data) {
    let url = `/user/userEntity/getMallInfo`;
    return request(url, data);
  }
  /**
* @description: 根据用户id获取活动数据
* @param {*}
* @return {*}
*/
  getActInfo(data) {
    let url = `/user/userEntity/getActInfo`;
    return request(url, data);
  }
  /**
  * @description: 根据用户id获取商城列表
  * @param {*}
  * @return {*}
  */
  getMallList(data) {
    let url = `/user/userEntity/getMallList`;
    return request(url, data);
  } 
  /**
  * @description: 客群导入方式
  * @param {*}
  * @return {*}
  */
  textAdd(data) {
    let url = `user/userGroupUser/userGroup/textAdd`;
    return request(url,data);
  }
}

export default new CustomerApi();
